<?php
	// On prolonge la session
	header('Content-type: text/html; charset=utf-8');
	session_start();
	$id_anim='';
	$code='';

	require_once('../../classes/database.php');
	$idconnect=Database::getInstance();


		// On teste si la variable de session existe et contient une valeur
		if(empty($_SESSION['id_anim'])){
			// Si inexistante ou nulle, on redirige vers la page de saisie du code
			header('Location: ../recherche.php');
			exit();
		}
		else{
			$id_anim=$_SESSION['id_anim'];
			$code=$_SESSION['code'];
		}
	
?>

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <link rel="stylesheet" href="../../style.css" />
        <?php
			require_once(dirname(__FILE__)."/onglet_animal.php");
			$onglet = affiche_onglets($_SESSION['membre_id']);
		?>
		<!--[if lt IE 9]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <!--[if lte IE 7]>
        <link rel="stylesheet" href="../../style_ie.css" />
        <![endif]-->
        <title>Base de données microcèbes</title>
    </head>

    <body>
		<?php include((dirname(dirname(dirname(__FILE__))))."/menu.php"); ?>

		<section id="main">
			<header>
				<h1>Recherche - Tests pratiqués sur l'animal <?php echo $code;?></h1>
			</header>
			<?php include((dirname(dirname(__FILE__)))."/menu_recherche.php"); ?>
			<section id="animal">
				<?php
					echo $onglet;
				?>

				<section id="contenu">
					<?php
						//récupération du nom des tests réalisés sur l'animal
						$query = pg_query($idconnect,"SELECT distinct label,description
						FROM resultat_test,test,type_test
						WHERE id_animal='".$id_anim."'
						AND resultat_test.id_test=test.id_test
						AND test.id_type_test=type_test.id_type_test");

						$int = pg_num_rows($query);
						if($int==0){echo("<p><label>Pas d'informations disponibles</label></p>");}
						else{
							echo "<ul>";
							while ($back = pg_fetch_assoc($query)) {
								if($back["label"]!="Test comportemental"){echo "<li>".$back["label"]."</li>";}
								else{echo "<li>".$back["description"]."</li>";}
							}
							echo "</ul>";
						}
					?>
					</ul>
				</section>
			</section>

		</section>
	</body>
</html>
